<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
          .bottom-bar{
            position: static;
            left: 0px;
            top: 0px;
            width: 100%;
            height: 60px;
            border-top: 1px solid #ccc;
            box-shadow: 0 0 8px #666;
            display: flex;
            flex-flow: row nowrap;
            align-items: center;
        }
        .bottom-bar > div{
            flex-grow: 1;
            text-align: center;
            cursor: pointer;
        }
        .bottom-bar > div:hover{
            color: orangered;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="bottom-bar">
                <div @click="change('HomePage')">首页</div>
                <div @click="change('ListPage')">列表</div>
                <div @click="change('CarPage')">购物车</div>
                <div @click="change('AboutPage')">关于我</div>
                <!-- <div @click="page='HomePage'">首页</div>
                <div @click="page='ListPage'">列表</div>
                <div @click="page='CarPage'">购物车</div>
                <div @click="page='AboutPage'">关于我</div> -->
        </div>
        <hr>
        <component v-bind:is="page"></component>

    </div>
    <script type="module">
        import { createApp } from "/assets/vue3/vue.esm-browser.js";
        import HomePage from "../动态组件/view/HomePage.js";
        import ListPage from "../动态组件/view/ListPage.js";
        import CarPage from "../动态组件/view/CarPage.js";
        import AboutPage from "../动态组件/view/AboutPage.js";
        createApp({
            data() {
                return {
                    page:'HomePage'
                }
            },
            components:{
                HomePage,ListPage,CarPage,AboutPage
            },
            methods: {
                change(page) {
                    this.page=page
                    location.hash=page
                }
            },
            created() {
                let page=location.hash.replace(/^#/,'')
                if(page!=''){
                    this.page=page
                }
            },
        }).mount("#app");
    </script>
</body>

</html>